<?php
include_once('admin_global.php');
$theme->add_block('body');
$usr=new bn_user();
$grid=new bn_grid();

$grid->update->enable=true;
$grid->update->caption=$lang[16];
$grid->update->cssclass="button blue";
$grid->delete->enable=true;
$grid->delete->caption=$lang[17];
$grid->delete->cssclass="button red";
$grid->header_show=true;
$grid->paging->enable=true;
$grid->paging->caption=$lang[75];
$grid->page_size=8;
$grid->msgdelete=$lang[45];
$grid->name='users';

$colid=new column();
$colid->caption=$lang[46];
$colid->field_name='id';
$colid->hide=true;
$colid->html_element_id='hiden_id';
$grid->columns->append($colid);

$coluser=new column();
$coluser->caption=$lang[1];
$coluser->field_name='user';
$coluser->html_element_id='user';
$grid->columns->append($coluser);

$colrol=new column();
$colrol->caption=$lang[48];
$colrol->field_name='rol';
$colrol->html_element_id='dropdownlist1';
$grid->columns->append($colrol);

$nikrol=new column();
$nikrol->caption=$lang[49];
$nikrol->field_name='nikname';
$grid->columns->append($nikrol);

$colmail=new column();
$colmail->caption=$lang[22];
$colmail->field_name='mail';
$colmail->html_element_id='mail';
$grid->columns->append($colmail);

$collang=new column();
$collang->caption=$lang[50];
$collang->field_name='lang';
$collang->html_element_id='default_language';
$grid->columns->append($collang);

$coldate=new column();
$coldate->caption=$lang[23];
$coldate->field_name='date';
$coldate->mask='per_date';
$grid->columns->append($coldate);

function per_date($date)
{
    return bndate('Y/n/d',$date);
}

if(isset($_POST['cmd']))
{
    extract($_POST);
    if($cmd=='delete')
    $usr->delete($id);
    if($cmd=='update')
    die(bn_redirect_postdata('user.php',array('cmd'=>'update','id'=>$users_id)));
   
    die($grid->show($usr->Select_all($col,$val)->fetch(),$users_page));
}

$theme->add_script($grid->command_script('#user'));
?>
<script>
$("#submit").live("click",function(){ 
                    $.post(window.location.href,{cmd:'search',col:$('#type').val(),val:$('#search').val()},function(data){$('#show').html(data)});
                    });
</script>
<div id="user">
<label><?= $lang[54] ?></label>
<select size="1" name="type" id="type" class="select">
	<option value="user">user</option>
	<option value="rol">rol</option>
	<option value="nikname">nikname</option>
	<option value="mail">mail</option>
</select>
<input type="text" size="35" autocomplete="on" name="search" id="search" class="input-text"/>
<input type="submit" name="submit" id="submit" value="<?= $lang[26] ?>" class="button"/>
<div id="show"><?= $grid->show($usr->Select_all()->fetch()); ?></div>
</div>
<?php
$theme->render();
?>